/*
 * @Author: your name
 * @Date: 2021-04-07 15:56:24
 * @LastEditTime: 2021-04-07 15:56:36
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \v3-ts\src\utils\message\index.ts
 */
import { message, Modal } from 'ant-design-vue';

class GlobalPack<T> {
  public message(content: T, type = 'warning'): void {
    message.config({
      duration: 2,
      maxCount: 1,
      top: '40px',
    });
    message[type]({ content });
  }
  public modal(content: T, type = 'error', okText = '确定'): Promise<boolean> {
    return new Promise((resolve, reject) => {
      Modal[type]({
        content,
        okText,
        onOk: () => {
          Modal.destroyAll();
          resolve(true);
        },
        onCancel: () => {
          Modal.destroyAll();
          reject(false);
        },
      });
    });
  }
}

export default new GlobalPack();
// import { ArgsProps, ConfigProps } from 'ant-design-vue/lib/notification';
// export declare type TypeMessage = 'success' | 'info' | 'error' | 'warning'

// export const Message = (content: string | undefined, type = 'warning'): void => {
//   message.config({
//     duration: 2,
//     maxCount: 1,
//     top: '40px',
//   });

//   message[type]({ content });
// };

// export const modal = (content: string | undefined, okText = '确定'): any => {
//   return new Promise((resolve, reject) => {
//     Modal.error({
//       title: 'Error',
//       content: content,
//       okText,
//       onOk: () => {
//         resolve(true);
//       },
//       onCancel: () => {
//         reject(false);
//       },
//     });
//   });
// };
